package com.eastone.user.serverapi.dao.impl;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;
import com.eastone.user.serverapi.dao.InfoAuthDao;
import com.eastone.user.serverapi.model.InfoAuth;
import com.yjx.framework.dao.impl.CommonDaoImpl;
import com.yjx.framework.util.StrUtil;

@Repository("infoAuthDao")
public class InfoAuthDaoImpl extends CommonDaoImpl<InfoAuth> implements InfoAuthDao {
	private Map<String, Object> getSqlParameterMap(String name, String code) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("name", StrUtil.isBlank(name) ? null : name);
		map.put("code", StrUtil.isBlank(code) ? null : code);
		return map;
	}

	@Override
	public List<InfoAuth> getList(String name, String code, int pageNo, int pageSize) {
		List<InfoAuth> resultList = getList(getSqlParameterMap(name, code), pageNo, pageSize);
		if (resultList == null) {
			resultList = Collections.emptyList();
		}
		return resultList;
	}

	@Override
	public int getCount(String name, String code) {
		Integer result = getCount(getSqlParameterMap(name, code));
		return result != null ? result.intValue() : 0;
	}
}
